package com.example.warehouse.mapper;

import com.example.warehouse.entity.Purchase;
import com.example.warehouse.page.Page1;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface purchaseMapper {

    @Insert("INSERT INTO buy_list (product_id,store_id, buy_num, fact_buy_num, buy_time, supply_id, place_id, buy_user, phone, is_in) VALUES " +
            "(#{productId},#{storeId},#{buyNum},#{factBuyNum},#{buyTime},#{supplyId},#{placeId},#{buyUser},#{phone},#{isIn})")
    void purchaseAdd(Purchase purchase);

    int findPurchaseCount(Purchase purchase);

    //@Param("page1") Page1 page1, @Param("user") User user
    List<Purchase> findPagePurchase(@Param("page")Page1 page1,@Param("purchase") Purchase purchase);

    @Delete("delete from buy_list where buy_id=#{buyId}")
    void deleteById(Integer buyId);

    @Update("UPDATE buy_list set buy_num=#{buyNum},fact_buy_num=#{factBuyNum} where buy_id=#{buyId}")
    void updatePurchase(Purchase purchase);

    @Update("update buy_list set is_in=1 where buy_id=#{buyId}")
    void setInById(Integer buyId);
}
